#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;

int minFallingPathSum(vector<vector<int>>& matrix) {
    int n = matrix.size();
    vector<vector<int>> dp(110, vector<int>(110, INT_MAX));

    for (int i = 0; i <= n; ++i)
    {
        dp[0][i] = 0;
    }

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            dp[i][j] = min(dp[i - 1][j], min(dp[i - 1][j - 1], dp[i - 1][j + 1])) + matrix[i - 1][j - 1];
        }
    }

    int ret = INT_MAX;
    for (int i = 1; i <= n; ++i)
        ret = min(dp[n][i], ret);

    return ret;
}

int main()
{

	return 0;
}